package com.xydtech.ecard.merchant.controller;

import com.xydtech.common.annotation.Log;
import com.xydtech.common.core.controller.BaseController;
import com.xydtech.common.core.domain.AjaxResult;
import com.xydtech.common.core.page.TableDataInfo;
import com.xydtech.common.enums.BusinessType;
import com.xydtech.common.utils.poi.ExcelUtil;
import com.xydtech.ecard.merchant.domain.EcardMerchantTask;
import com.xydtech.ecard.merchant.service.IEcardMerchantTaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 电子名片商户任务记录controller
 *
 * @author yuzhiguo
 * @date 2024-05-22 下午5:39
 */
@Controller
@RequestMapping("/merchant/task")
public class EcardMerchantTaskController extends BaseController
{
    private String prefix = "merchant";

    @Autowired
    private IEcardMerchantTaskService ecardMerchantTaskService;

    @RequiresPermissions("merchant:task:view")
    @GetMapping()
    public String task()
    {
        return prefix + "/merchantTask";
    }

    /**
     * 查询商户超时拜访预警列表信息
     */
    @RequiresPermissions("merchant:task:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EcardMerchantTask ecardMerchantTask)
    {
        ecardMerchantTask.setMerchantType("2");//商户类型：1-个人，2-商户，3-企业，4-新型农业主体
        startPage();
        List<EcardMerchantTask> list = ecardMerchantTaskService.selectMerchantTaskList(ecardMerchantTask);
        return getDataTable(list);
    }

    /**
     * 导出商户超时拜访预警列表信息
     */
    @RequiresPermissions("merchant:task:export")
    @Log(title = "电子名片商户超时拜访预警列表信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(EcardMerchantTask ecardMerchantTask)
    {
        ecardMerchantTask.setMerchantType("2");//商户类型：1-个人，2-商户，3-企业，4-新型农业主体
        List<EcardMerchantTask> list = ecardMerchantTaskService.selectMerchantTaskList(ecardMerchantTask);
        ExcelUtil<EcardMerchantTask> util = new ExcelUtil<EcardMerchantTask>(EcardMerchantTask.class);
        return util.exportExcel(list, "电子名片商户超时拜访预警列表信息");
    }
}
